<?php
class Jpgraph {
    function linechart($ydata, $title='Line Chart')
    {
        require_once("jpgraph/jpgraph.php");
        require_once("jpgraph/jpgraph_line.php");    
        
        // Create the graph. These two calls are always required
        $graph = new Graph(350,250,"auto",60);
        $graph->SetScale("textlin");
        
        // Setup title
        $graph->title->Set($title);
        
        // Create the linear plot
        $lineplot=new LinePlot($ydata);
        $lineplot->SetColor("blue");
        
        // Add the plot to the graph
        $graph->Add($lineplot);
        
        return $graph; // does PHP5 return a reference automatically?
    }
	
	function barchart($ydata, $xlegend, $title='Bar Chart')
    {
        require_once("jpgraph/jpgraph.php");
        require_once("jpgraph/jpgraph_bar.php");    
        
        // Create the graph. These two calls are always required
        $graph = new Graph(350,250,"auto",60);
        $graph->SetScale("textlin");
        
		// Add a drop shadow
		$graph->SetShadow();
		
		
		
        // Setup title
        $graph->title->Set($title);
		$graph->xaxis->title->Set('Ciclos Evaluados');
		$graph->yaxis->title->Set('Promedio');
		
		$graph->xaxis->SetTickLabels($xlegend);
        
        
        $graph->yaxis->scale->SetGrace(20);
		$bplot = new BarPlot($ydata);
		$bplot->SetColor("blue");
		$bplot->value->SetFormat('%d');
		$bplot->value->Show();
		$bplot->value->SetColor('#FFFFFF');
		$bplot->SetShadow();

 
        
        // Add the plot to the graph
        $graph->Add($bplot);
        
        return $graph; // does PHP5 return a reference automatically?
    }
} 